//侧边栏
$('.slide_top').click(function () { $('html,body').animate({ scrollTop: '0px' }, 400); });
$('.glyphicon-download').click(function () { $('html,body').animate({ scrollTop: '10500px' }, 400); });

$('#aside>div').hover(function () {
    $(this).find('section').show()
}, function () {
    $(this).find('section').hide()

})
$('.div').hover(function () {

    $('.span').css({

        transform: 'rotate(180deg)'
    })
    $('.slide_down').css({ display: 'flex' })

}, function () {
    $('.slide_down').hide()
    $('.span').css({

        transform: 'rotate(360deg)'
    })

})

//划过出现下划线
$(function () {
    $('#nav li').mouseover(function () {

        $(this).css({
            borderBottom: '4px solid yellow',
            color: 'white',

        })
    })
    $('#nav li').mouseout(function () {

        $(this).css({
            border: 'none',
            color: 'rgb(170, 170, 170)',

        })

    })


})
//获取数据请求
$.get('http://localhost:3000/pro-list', function (res) {
    console.log(res);
    let html = ''
    res.forEach(v => {
        html += `
    <a href="detail.html?pid=${v.pid}" target='_blank'>
    <section class="shadow">
    <div>
    <img src="${v.pimg}" alt="" width="278" height="268"></div>
    <p>${v.pitle}</p>
    <p style="color: rgb(177, 40, 40);">${v.pprice}</p>
    </section>
    </a>
    `
    });
    $('#main-list').html(html)

    //商品滑过阴影效果
    $(".shadow").hover(function () {
        $(this).animate({
            top: '-5'
        }, '2000', "linear", function () {
            $(this).css({
                boxShadow: ' 0 5px 10px 0px rgb(150,150,150) '
            })
        });

    }, function () {
        $(this).animate({
            top: 0
        }, 500, 'linear', function () {
            $(this).css({
                boxShadow: '0 0 0 0'
            })
        })
    });
    let user = localStorage.getItem('uid')
    $.get('http://localhost:3000/card', function (res) {
        // console.log(res[0].data);
        res.forEach(a => {
            // console.log(a.uid,user);
            if (a.uid == user) {
                //  console.log(a.data);
                let arr = JSON.parse(a.data)
                //  console.log(arr);
                $('.cart span').html(arr.length)
            }
        })
    }, 'json')

}, 'json')

